const Router = require('koa-router');
const {db, Op,QueryTypes } = require("../../models/db");
const tool = require("../../tools/tool");
const router = new Router();

// 购物车数量
router.post('/zd/getCartNum', async ctx => {
    let usr = ctx.user
    let tenantId = usr.tenantId
    let sql = `select sum(qty) qty from cart_zd where tenantId=${tenantId} and buId=${usr.buId} group by tenantId,buId `
    let ret = await db.query(sql, {type: QueryTypes.SELECT, plain: true},)
    return ctx.suc('', ret ? ret.qty : '')

})

module.exports = router;
